package com.hyzh.latte.sandtable.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.repository.query.Param;

@Mapper
@DS("sadt")
public interface TableMapper {
    @Update("CREATE TABLE IF NOT EXISTS ${tableName} (" +
            "index SERIAL PRIMARY KEY, " +
            "start_x DOUBLE PRECISION, " +
            "start_y DOUBLE PRECISION, " +
            "end_x DOUBLE PRECISION, " +
            "end_y DOUBLE PRECISION, " +
            "length DOUBLE PRECISION, " +
            "geom GEOMETRY(LineString, 4326))")
    void createLineTable(@Param("tableName") String tableName);

    @Update("CREATE TABLE IF NOT EXISTS ${tableName} (" +
            "index SERIAL PRIMARY KEY, " +
            "x DOUBLE PRECISION, " +
            "y DOUBLE PRECISION, " +
            "geom GEOMETRY(Point, 4326))")
    void createNodeTable(@Param("tableName") String tableName);
}
